//求1！+2！+3！+4！+........+n!的和

import java.util.Scanner;

public class Test17 {
    public static void main(String[] args) {
        System.out.println("请输入一个数字：");
        Scanner scanner=new Scanner(System.in);
        int num =scanner.nextInt();
        func(num);
    }

    private static void func(int num) {
        int get=0;
        for (int i = num; i >=1 ; i--) {
            int sing=1;
            for (int j =1; j <=i ; j++) {
                sing*=j;
            }
            get+=sing;
        }
        System.out.println("则其各个阶乘和为"+get);
    }
}
